package com.mapreduce;

import com.bean.IdFlag;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

public class IdPar extends Partitioner<IdFlag, Text> {
    @Override
    public int getPartition(IdFlag idFlag, Text text, int numPartitions) {
        // 将编号相同的数据放到同一个分区下
        return (Math.abs(
                idFlag.getId().hashCode())*127)%numPartitions;
    }
}
